package net.gylka.newsreader;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class ArticleListAdapter extends ArrayAdapter<Article> {

	private ArrayList<Article> mArticleList;
	
	public ArticleListAdapter(Context context, int textViewResourceId, List<Article> objects) {
		super(context, textViewResourceId, objects);
		this.mArticleList = (ArrayList<Article>) objects;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View itemView = convertView;
		if (convertView == null) {
			LayoutInflater inflater = (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			itemView = inflater.inflate(R.layout.list_article_item, parent, false);
		}
		TextView txtArticleTitle = (TextView) itemView.findViewById(R.id.txtArticleTitle);
		txtArticleTitle.setText(mArticleList.get(position).getTitle());

		itemView.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
			}
			
		});
	
		return itemView;
	}
	

}
